Skip to content

Fixes to from_imr_result() workflow#121

Merged
maxisi merged 7 commits intomaxisi:igwnfrom
nkhusid:from-imr-result
Sep 24, 2025
Merged

Fixes to from_imr_result() workflow#121
maxisi merged 7 commits intomaxisi:igwnfrom
nkhusid:from-imr-result

Conversation

@nkhusid
Copy link
Contributor

@nkhusid nkhusid commented Sep 23, 2025

I've fixed a few small bugs that arise in the rd.Fit.from_imr_result() workflow.

utils.py

Upon reading in the PE configs to store IMRResult attributes, some were stored with either extraneous characters or faulty dict patterns. In utils.py, get_bilby_dict() was at times not removing all space characters and incorrectly splitting the string for a case like '{ H1:448,L1:448, }'. I added a ' ' to the characters to remove, and also conditioned the splitting of each new sub-string from d.split(',') on there being a ':' in the sub-string.

fit.py

In the analysis workflow, we sometimes want to indicate a particular set of PE to load from an event's IMR result dataset, i.e. PE with a desired approximant. In IMRResult.from_pesummary() there is a group keyword argument, but at the abstracted rd.Fit.from_imr_result() level, the user cannot specify a group of the IMR .hdf5 file; rather the group defaults to NRSur7dq4 PE or, if unavailable, the first listed group in the dataset keys. I added an imr_kws argument to from_imr_result(), which gets propagated to the IMRResult constructor and further to from_pesummary() in imr.py, such that the user can specify the group from the top level.

data.py

For PSD interpolation, I noticed that cubic interpolation does a poor job for especially spiky PSDs (the interpolation tends to reflect the sharp spikes down to orders of magnitude smaller numbers, producing a PSD that is reminiscent of a round-trip PSD with a too large dynamic range). I've switched to linear interpolation instead, see a comparison below:

cubic linear
image image

In some cases, the number of points on the uniformly spaced frequency grid, n in PowerSpectrum.interpolate_to_index() in data.py, was too few; this results in the wrong delta_t = 1/(2*max(freq)), or the wrong Nyquist frequency according to the highest frequency bin in the interpolated PSD frequency array. I changed n to be equal to the same number of points as in the initial frequency array to ensure the correct Nyquist frequency.

imr.py

If PSDs are added as an IMRResult attribute via IMRResult.set_psds(), then they are interpolated to a uniform frequency grid by default. However, when an IMRResult object is instantiated, the PSDs read in from the .hdf5 file are not immediately interpolated. I've added default PSD interpolation to the construction of the IMRResult object in from_pesummary().

Additionally, for some GW events, the reference-frequency is set to be lower than the minimum-frequency for each ifo; in these cases, the waveform generation for signal templates in the detectors breaks because f_ref cannot be less than f_min. For these events, I've implemented a fix that passes the starting frequency (f_start, or equivalently waveform in the minium-frequency dict in the PE config) as the f_low argument in IMRResult.get_waveforms(), rather than the ifo minimum frequency.

Finally, in some cases the IMRResult.ifos was storing detectors as ["'H1'", "'L1'"], so I modified the ifos attribute to remove any spurious quotations.

@maxisi maxisi merged commit 7283651 into maxisi:igwn Sep 24, 2025
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants